﻿using Mes.Domain.BoundedContext.Entities.Quality;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Quality
{
    public class SampleToGoEntityConfig : IEntityTypeConfiguration<SampleToGo>
    {
        public void Configure(EntityTypeBuilder<SampleToGo> builder)
        {
            builder.ToTable("sample_to_go");
            builder.HasKey(b => b.Sample_Id);
            builder.Property(b => b.Ent_Id).IsRequired();
            builder.Property(b => b.Sample_Name).HasMaxLength(80);
            builder.Property(b => b.Wo_Id).HasMaxLength(40);
            builder.Property(b => b.Oper_Id).HasMaxLength(40);
            builder.Property(b => b.Seq_No);
            builder.Property(b => b.Context_Ent_Id);
            builder.Property(b => b.Item_Id);
            builder.Property(b => b.Item_Category_Id);
            builder.Property(b => b.Process_Id).HasMaxLength(40);
            builder.Property(b => b.Context_Oper_Id).HasMaxLength(40);
            builder.Property(b => b.Freq_Id);
            builder.Property(b => b.Plan_Id);
            builder.Property(b => b.Requested_Time_Utc).IsRequired();
            builder.Property(b => b.Requested_Time_Local).IsRequired();
            builder.Property(b => b.Expiry_Time_Utc);
            builder.Property(b => b.Expiry_Time_Local);
            builder.Property(b => b.Warning_Time_Utc);
            builder.Property(b => b.Warning_Time_Local);
            builder.Property(b => b.Sample_Name_Template).HasMaxLength(80);
            builder.Property(b => b.Sample_Name_Instance).HasMaxLength(80);
            builder.Property(b => b.Current_Sample_No);
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Sample_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 1, incrementBy: 1, minValue: 1);
        }
    }
}
